<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
//     function myFunction() {
//    document.getElementById("demo").innerHTML = "段落被更改。";
// }


// var aa = ["zhangsan","lisi","wangwu"]
// var ab = [18,17,16]
// for (let ab = 0; ab < array.length; ab++) {
//     const element = array[ab];
    
// }
var persons = [{name:'zhangsan',gae:18},{name:'lis',gae:17},{name:'wangwu',gae:20}]

// for (var item in persons) {
//     console.log(persons[item])

//     if (persons[item].gae >= 20) {
//         console.log(persons[item].name)
        
//     }
// }

// for(var item of persons) {
//     console.log(item)

//     if (item.gae>=20) {
//         console.log(item.name)
//     }
// }

// for (let index = 0; index <= persons.length-1; index++) {
//     console.log(persons[index])
    
//     if (persons[index].gae >= 20) {
//         console.log(persons[index])
//     }
// }

function myFunction(a,b) {
    
    
    return a*b;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
}
console.log(myFunction(13,17))

zhangsan= {
    name:'zhangsan',age:18
}

zs = new Object()
zs.name = 'xxxx';
zs.age = 88;
console.log('zs[name]',zs[name])
console.log('zs[name]:',zs['name'])

function Stu(name, age) {
    this.name = name;
    this.age = age;
    this.getName = function () {
        console.log("my name is",this.name)
    }

    this.getage= function () {
        console.log("my age is",this.age)
    }
}

s1 = new Stu('zhangsan',20);
s1.getName();
s1.getage();


s1.getNameAndAge = function(a,b) {
    console.log(this.name,":",this.age,":",a,":",b)
};
s1.getNameAndAge("x","y");

s2 = new Stu('lisi',21)
s2.getName();
s2.getage();
s1.getNameAndAge.apply(s2,["x","y"])
s1.getNameAndAge.call(s2,"x","y")




</script>






<body>

<!-- <p id="demo">一个段落</p>
<button type="button" onclick="myFunction()">试一试</button> -->
</body>
</html>